<script>
  //1
  const promise1 = Promise.all([
    new Promise(resolve => resolve(1)),
    new Promise(resolve => resolve(2)),
    new Promise(resolve => resolve('a')),
    new Promise(resolve => resolve(3))
  ]);
  promise1
    .then(value => { console.log(value) })// 希望进入到then打印[1,2,'a',3]应该怎么写？
    .catch(e => console.log(e));

  //2
  const lateRejectedPromise = new Promise((resolve, reject) => setTimeout(reject, 100));
  const earlyResolvingPromise = new Promise(resolve => resolve('成功！！'));
  const promise2 = Promise.race([lateRejectedPromise, earlyResolvingPromise]);
  promise2
    .then(value => { console.log(value) }) // 希望进入到then打印'成功！！'
    .catch(e => console.log('失败'));

  //3
  class NotRejectedError extends Error {
    constructor() {
      super();
      this.message = '被抛出的错误。';
    }
  }
  const earlyRejectedPromise = new Promise((resolve, reject) => setTimeout(() => reject('我是失败者'), 10));
  const lateResolvingPromise = new Promise(resolve => setTimeout(resolve, 10));
  const promise3 = Promise.race([earlyRejectedPromise, lateResolvingPromise]);
  promise3
    .then(() => new NotRejectedError())
    .catch(value => { console.log(value) }) // 希望进入catch打印 '我是失败者'

  //4
  const promise4 = Promise.resolve();
  promise4
    .then(value => { console.log(undefined === value) }) // 希望进入then 打印 true
    .catch(e => done(new Error('失败：' + e)));

  //5
  const promise5 = Promise.resolve('解决了');
  promise5
    .then(value => { console.log(value) }) // 希望打印 '解决了'

  //6
  const p = Promise.resolve();
  console.log(typeof p.catch === 'function'); // 使这一行的打印为 true

  //7
  const whatToReturn = () => Promise.resolve();
  const promise7 = Promise.reject(); // 不要改变这一行
  promise7.catch(() => whatToReturn())
    .then(() => console.log('成功')) // 希望进入这里
</script>